The present invention relates to microcontrollers, and, more particularly, to a method for resetting a microcontroller including a reset sequence to make the microcontroller go from a power-off mode to a run mode when the level of a supply voltage goes over a threshold.
A microcontroller is an electronic circuit including a central processor unit or core, an EPROM or EEPROM memory, a main oscillator, one or more analog-digital converters, input-output interfaces and possibly peripheral circuits. The advantage of a microcontroller as compared with a microprocessor is that the microcontroller can be used in an autonomous way. That is, practically no external circuitry is needed for their operation. This is why their use is very widespread in relatively straightforward applications, such as in small electronic items.
Resetting the microcontroller is done in a power-on reset operation. It can also be prompted by an external reset signal, or by a reset signal coming from an internal circuit of the microcontroller called a watchdog circuit. The microcontroller can also be reset by a signal from a low voltage detector circuit which detects an excessively low level of supply voltage.
The power-off mode is particularly important when detecting an excessively low level of supply voltage, wherein the level of the supply voltage is not stable. In the power-off mode, all the internal circuits of the microcontroller are inhibited such that these circuits do not function. An exception is for a reset sequence dedicated to the management of the reset sequence. Thus, the drawbacks that could result from an operation of the microcontroller with an excessively low supply voltage are avoided. Example drawbacks are corruption or loss of data, poor sequencing of instructions due to defective clock signals, etc.
The microcontroller does not go into the run mode from a power-off mode except when the level of the supply voltage at a power supply input has become greater than the above-mentioned threshold. Between these two modes, the microcontroller is said to be in a reset mode. The run mode is the normal mode of operation in which the program loaded by the user into the memory of the microcontroller is performed. This program is known as the user program.
The reset sequence starts when the level of supply voltage becomes greater than the above-mentioned threshold. It includes a time-lag phase during which the main oscillator of the microcontroller is released, so that it starts oscillating and becomes stabilized at its nominal oscillating frequency. The duration of this phase is fixed and corresponds to a time necessary to enable this stabilization. During this phase, the reset sequence and the main oscillator are the only internal circuits of the microcontroller that are not inhibited or no longer inhibited.
The reset sequence furthermore includes a step or phase for loading the address bus with the address of the memory, i.e., fetch vector, at which the start of the user program is located. This step ends the reset sequence and the microcontroller goes into the run mode.
It is necessary to provide the user with the possibility of configuring certain circuits of the microcontroller to adapt them to the needs of the application. This operation of configuration must not be mistaken for the loading of the user program into the memory of the microcontroller. The configuring operation is designed to activate or deactivate certain functions of the microcontroller, or to customize them. It is therefore a hardware configuration as opposed to software for loading the user program. Furthermore, unlike loading of the user program, this configuring operation is renewed at each resetting. For example, it may be desirable to enable the user to activate or deactivate the low voltage detector circuit and/or to choose the level of the threshold below which it generates a resetting signal.
In the prior art, this is sometimes obtained by reading an option word that is stored in the memory of the microcontroller. This step operates in the run mode. The values of the bits of this option word that are read position the dedicated registers of the microcontroller. The option word may be read statistically, i.e., permanently by the microcontroller. The option word may also be read dynamically by a specific instruction that the user must place at the beginning of the user program, for example.
However, this method is not applied to the configuring of the circuits of the microcontroller that operate in the reset sequence, such as the reset sequence and the main oscillator. This is because it was not thought possible to apply this method before the microcontroller was in the run mode. During the reset sequence, all the internal circuits of the microcontroller are inhibited except for the reset sequencer itself. During the time-lag phase, all the internal circuits of the microcontroller are inhibited except for this resetting sequencer as well as the main oscillator.
It may be desirable to enable the user to choose the value of the resetting threshold. The user may prefer to choose this value himself based upon the particular application. The higher the resetting threshold, the more reliable is the operation of the microcontroller. A high resetting threshold ensures that the microcontroller is in a run mode only when the supply voltage is very adequate for the proper operation of its internal circuits. Conversely, the higher the resetting threshold the greater the time during which the microcontroller may remain in a power-off mode.
In the prior art, one approach known for obtaining a resetting threshold that can be configured by the user is in the use of a circuit external to the microcontroller, which is typically an analog circuit that the user is free to adapt to his needs. External configuration circuits of this kind are nevertheless penalizing inasmuch as they make it more complicated and more costly to install the microcontroller in an intended application.
The present invention seeks to overcome the above described drawbacks of the prior art. The invention provides a method for the resetting of a microcontroller wherein the reset sequence comprises the following steps: a) reading an option word stored in a programmable memory by the user for the configuration of the internal circuits of the microcontroller; b) a time-lag phase for the starting and stabilizing of the main oscillator of the microcontroller; and c) loading of the address bus with the starting address of a user program stored in the memory of the microcontroller. The internal circuits of the microcontroller thus operate in the reset sequence, and can be configured by the user by programming a specified option word in the memory of the microcontroller.
Other characteristics of the invention include the following. The step a) starts when the level of the supply voltage becomes greater than a configuration threshold. The configuration threshold is not configurable. The configuration comprises the specification of the value of a resetting threshold higher than the configuration threshold. The step b) starts when the level of the supply voltage becomes greater than this resetting threshold but not before the end of step a).
Additional characteristics include the following. The step b) starts at the end of step a). The step a) is performed at the rate of a low frequency back-up oscillator. The configuration comprises the selection of a source for the main oscillator of the microcontroller from among, in particular, one or more external resonators having different frequencies, an external RC circuit, an internal RC circuit or an external clock. The configuration comprises the activation or non-activation of a clock filtering circuit. The option word is stored in the memory of the microcontroller.